Ping : Network ping probe
This module provides a network ping function, typically used to diagnose network connection status. This module is supported in EdgerOS 1.8.8 and later.
User can use the following code to import the ping
module.
var ping = require("ping");
Support
The following shows ping
module APIs available for each permissions.
User Mode | Privilege Mode | |
---|---|---|
ping.ping | ● | ● |
Ping Functions
ping.ping(ipaddr[, opt], callback)
ipaddr
{String} IPv4 or IPv6 address.opt
{Object} Ping option.callback
{Function} Return ping results.error
{Error} Indicate failure information when ping fails.
Ping the specified remote host. The parameters that opt
can contain are as follows:
Parameter | Type | Description | Defaults | Allowable |
---|---|---|---|---|
ttl | Integer | Send packet IP TTL | 64 | 1 ~255 |
size | Integer | Payload size | 32 | 0 ~65500 |
timeout | Integer | Wait time for echo (ms) | 3000 | 0 ~60000 |
dev | String | Device to binding | undefined | - |
Example
var { ping } = require("ping");
// Ping IPv4
ping("127.0.0.1", function(error) {
if (error) {
console.error("ping 127.0.0.1 error:", error);
} else {
console.log("ping 127.0.0.1 ok!");
}
});
// Ping IPv6
ping("::1", function(error) {
if (error) {
console.error("ping ::1 error:", error);
} else {
console.log("ping ::1 ok!");
}
});
JSRE limit: only ping up to 32 targets at the same time.